#!/bin/bash
# 启动 zero2prod
# 参数：环境名

# 查询数据库列表：
# SELECT datname FROM pg_database;
# 删除数据库：
# DROP DATABASE "xxxxx";

# 种子用户/密码：admin/everythinghastostartsomewhere

env=ssh
if [ $# -ge 1 ]; then
	env=$1
fi

if [ "$env" == "ssh" ]; then
	export APP_ENVIRONMENT=ssh
	export DATABASE_URL=postgres://postgres:password@10.67.75.207:5432/newsletter
elif [ "$env" == "local" ]; then
	export APP_ENVIRONMENT=local
	export DATABASE_URL=postgres://postgres:password@localhost:5432/newsletter
else
	export APP_ENVIRONMENT=prod
	export DATABASE_URL=postgres://postgres:password@10.67.75.207:5432/newsletter
fi
export RUST_LOG=debug
cargo run | bunyan
